/*
 * @Author: jianfanfan 1217572833@qq.com
 * @Date: 2025-03-15 19:08:37
 * @LastEditors: jianfanfan 1217572833@qq.com
 * @LastEditTime: 2025-03-15 19:12:37
 * @FilePath: \guozaoke\src\auth\register.dto.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { IsEmail, IsString, MinLength, Length, Matches } from 'class-validator';

export class RegisterDto {
  //用户名由字母开头，只能含有字母、数字或者下划线
  @IsString()
  @MinLength(3)
  @Length(3, 16, { message: '用户名长度必须在 3 到 16 个字符之间' })
  @Matches(/^[a-zA-Z][a-zA-Z0-9_]*$/, {
    message: '用户名必须以字母开头，并且只能包含字母、数字或下划线',
  })
  username: string;

  @IsEmail()
  email: string;

  @IsString()
  @MinLength(6)
  password: string;

  // 确认密码
  @IsString()
  @MinLength(6)
  confirmPassword: string;
}
